﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using Psm.Logging;
using Psm.Container;
using System.Diagnostics;

namespace Psm.Host
{
    class Program
    {
        static void Main(string[] args)
        {
            SetConsole();

            try
            {
                Repository.Initialize();

                ILogger logger = Repository.GetInstance<ILogger>();
                Psm.Core.PsmServer server = new Core.PsmServer();
                server.Start();
                logger.Info("Startup Completed");
                Console.ReadKey();

                logger.Info("Shutting down...");
                server.Stop();
                logger.Info("Shutdown Completed");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace.ToString());
                Console.ReadKey();
            }
            
            Console.ReadKey();
        }

        private static void SetConsole()
        {
            Console.SetBufferSize(500, 2000);
            Console.SetWindowPosition(0, 0);
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            Console.ForegroundColor = ConsoleColor.White;
            Console.Title = Process.GetCurrentProcess().ProcessName;
        }
    }
}
